package com.sky.controller.rider;

import com.sky.dto.UserLoginDTO;
import com.sky.pojo.Courier;
import com.sky.result.Result;
import com.sky.service.rider.CourierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/courier")
@Slf4j
@Api(tags = "骑手服务")
public class CourierController {

    @Autowired
    private CourierService courierService;

    @PostMapping("/login")
    @ApiOperation("骑手登录")
    public Result<Courier> login(@RequestBody UserLoginDTO loginDTO){
        log.info("骑手登录 -- {}", loginDTO);

        return courierService.login(loginDTO);
    }

    @GetMapping("/receivingOrder")
    @ApiOperation("骑手接单")
    public Result<String> receivingOrder(Long courierId, String tradeNo){
        log.info("骑手接单 -- {} -- {}", courierId, tradeNo);

        return courierService.receivingOrder(courierId, tradeNo);
    }

    @GetMapping("/transferOrderToTaskPool")
    @ApiOperation("骑手转单求助")
    public Result<Courier> transferOrderToTaskPool(String tradeNo, Long courierId){
        log.info("骑手转单求助 -- {} -- {}", tradeNo, courierId);

        return courierService.transferOrderToTaskPool(tradeNo, courierId);
    }
}
